import React, { FC, ChangeEvent, PropsWithChildren } from 'react'

import Select from 'react-select'
interface Props extends PropsWithChildren<any> {
  options: any
  placeholder: string
  code: string
  onChange?: (value: ChangeEvent<HTMLInputElement>) => void
  onFocus: () => void
  onInputChange: (value: ChangeEvent<HTMLInputElement>) => void
}

const SelectSearch: FC<Props> = ({ placeholder, code, options, onInputChange, onChange, onFocus }) => {
  console.log(code)
  return (
    <Select
      className='react-select'
      options={options}
      placeholder={placeholder}
      defaultValue={code}
      onInputChange={(e: any) => {
        typeof onInputChange === 'function' && onInputChange(e)
      }}
      onFocus={onFocus}
      onChange={(e: any) => {
        typeof onChange === 'function' && onChange(e)
      }}
    />
  )
}
export default SelectSearch
